<?php
/**
 * Created by JetBrains PhpStorm.
 * User: q
 * Date: 14-8-17
 * Time: 上午10:03
 * To change this template use File | Settings | File Templates.
 */
class Weightpic_model extends CI_Model{
    private $table = 'pic';
    function __construct(){
        parent::__construct();
    }
    public function insert($data){
        $this->db->insert($this->table,$data);
    }
    public function update($openid,$pic,$date){
        $this->db->where('date',$date);
        $this->db->where('openid',$openid);
        $this->db->set('pic',$pic);
        $this->db->update($this->table);
    }

    /**
     * @param $date
     * @param $openid
     * @return bool
     * 如已存在 返回false 反之返回true
     */
    public function check($date,$openid){
        $openid = (string)$openid;
        $this->db->where('date',$date);
        $this->db->where('openid',$openid);
        $result = $this->db->get($this->table)->row_array();
        if($result){
            return false;
        }else{
            return true;
        }
    }
}